$(function(){
	cambiar_login();
});
/**
 * HTML5向Web API新引入了document.querySelector以及document.querySelectorAll两个方法用来更方便地从DOM选取元素
 */
function cambiar_login() {
	  document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_login";  
	document.querySelector('.cont_form_login').style.display = "block";
	document.querySelector('.cont_form_sign_up').style.opacity = "0";               
	
	setTimeout(function(){  document.querySelector('.cont_form_login').style.opacity = "1"; },400);  
	  
	setTimeout(function(){    
			document.querySelector('.cont_form_sign_up').style.display = "none";
		},200);  
  }

function cambiar_sign_up(at) {
	document.querySelector('.cont_forms').className = "cont_forms cont_forms_active_sign_up";
	document.querySelector('.cont_form_sign_up').style.display = "block";
	document.querySelector('.cont_form_login').style.opacity = "0";
	  
	setTimeout(function(){  
		document.querySelector('.cont_form_sign_up').style.opacity = "1";
	},100);  
	
	setTimeout(function(){   
		document.querySelector('.cont_form_login').style.display = "none";
	},400);  
}    



function ocultar_login_sign_up() {

	document.querySelector('.cont_forms').className = "cont_forms";  
	document.querySelector('.cont_form_sign_up').style.opacity = "0";               
	document.querySelector('.cont_form_login').style.opacity = "0"; 

	setTimeout(function(){
		document.querySelector('.cont_form_sign_up').style.display = "none";
		document.querySelector('.cont_form_login').style.display = "none";
	},500);  
  
  }

new Vue({
	
	el : '#login_register',
	data : {
		tip_message : "",
		tip_message_password : "",
		log_uc : '',
		log_un : '',
		log_pa : '',
		log_pa2 : '',
		user : {}
	},
	methods : {

		gotoRegister : function(){
			
			$.ajax({
				url : COMMON_URL.URL+"userMessage/saveUser",
				type : 'POST',
				data : JSON.stringify(this.user),
				contentType : 'application/json',
				dataType : 'json',
				success : function(result){
				
					if(result.ok){
						swal({
					        title: "成功",
					        text: result.msg,
					        type: "success",
					        showCancelButton: true,
					     	confirmButtonText: "是",
					        cancelButtonText: " ",
					        closeOnConfirm: true,
					        closeOnCancel: true
						},function(isOk){
							if(isOk){
								window.location.href = COMMON_URL.URL;
							}
						});
						
					}else{
						swal(result.msg,"","error");
					}
				}
				
			});
			
		},
		
		password_on : function(val){
			var password = this.$refs.password2.value;
			var configpaw = this.$refs.password2_1.value;
			
			if(password != configpaw){
				this.tip_message_password = '两次密码不一致';
			}else{
				this.tip_message_password = '';
			}
		}
		
	} 
	
});

